#pragma once
#include "../Graphics/2D/Window2D.h"
#include "../Graphics/2D/core/Scene.h"
#include "../Graphics/Render.h"
#include "../Physics/Physic2D/Physic2DWorld.h"

class GameEngine {
public:
	GameEngine();
	~GameEngine() {
	}
	void start() {}

	void init();

	void loopGame();

	Render* getRender() {
		return render;
	}
	void keyReleaseEvent(QKeyEvent* event);
	void keyPressEvent(QKeyEvent* event);

protected:
	void doKeyEvent();
	void updateShapePhysic() {
		QMap<Body*, Shape*>::const_iterator bodyShape;
		for (bodyShape = this->bodyMapingShape->constBegin(); bodyShape != this->bodyMapingShape->constEnd(); ++bodyShape) {
			Body* body = bodyShape.key();
			Shape* shape = bodyShape.value();
			shape->setPosition(body->getPosition());
			shape->setAngle(body->getAngle());
		}
	}

private:
	Scene* scene;
	Render* render;
	Physic2DWorld* world;
	QMap<Body*, Shape*>* bodyMapingShape = new QMap<Body*, Shape*>();
	QElapsedTimer* elapsedTimer = new QElapsedTimer();
	Body* player;
};
